<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>AUI快速完成布局</title>
    <link rel="stylesheet" type="text/css" href="../aui/css/aui.css" />
    <script type="text/javascript" src="/static/js/jquery-1.10.1.min.js"></script>
    <script type="text/javascript" src="/static/js/template-web.js"></script>
</head>
<body>
<div style="padding: 10px; font-size: 16px; cursor: pointer;" onclick="history.go(-1)">&laquo;返回</div>
<div id="main" style="margin:0 10%;width:80%"></div>
<div id="push_more" onclick="push_more_circe()" class="aui-col-xs-12" style="text-align:center">
    <p>拉取更多</p>
    <i class="aui-iconfont aui-icon-down"></i>
</div>

</body>
<script id="circle_info" type="text/html">
{{each info as item i}}
<div class="aui-card-list">
        <div class="aui-card-list-header aui-card-list-user aui-border-b">
            <div class="aui-card-list-user-avatar">
                <img src="{{ item.avatar }}" class="aui-img-round" />
            </div>
            <div class="aui-card-list-user-name">
                <div>{{ item.nick_name }}</div>
            </div>
            <div class="aui-card-list-user-info">{{ item.create_time }}</div>

        </div>

        <div class="aui-card-list-content-padded">
            {{ item.content }}
        </div>

        <div class="aui-card-list-content-padded aui-border-b aui-border-t">
            <div class="aui-row aui-row-padded">
                {{ each item.images as img j}}
                <div class="aui-col-xs-1" style="height: 100px">
                    <img src="{{ img }}" style="height:100%;"/>
                </div>
                {{/each}}
            </div>
        </div>

        <div class="aui-card-list-footer aui-border-t">
            {{ if item.is_using == 1 }}
                <div id="div{{ item.reply_id }}" onclick="chan_reply_status({{ item.reply_id }}, 1)"><i id="i{{ item.reply_id }}" class="aui-iconfont aui-icon-display" ></i><span id="span{{ item.reply_id }}">可见</span></div>
            {{ else }}
                <div id="div{{ item.reply_id }}" onclick="chan_reply_status({{ item.reply_id }}, 2)"><i id="i{{ item.reply_id }}" class="aui-iconfont aui-icon-hide" ></i><span id="span{{ item.reply_id }}">已屏蔽</span></div>
            {{/if}}
        </div>
    </div>
{{/each}}


</script>
<script type="text/javascript">

    //获取url中的参数
    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg);  //匹配目标参数
        if (r != null) return unescape(r[2]); return null; //返回参数值
    }


    function push_more_circe(reply_id) {
        $.ajax( {
            url:'/replylist?c_id='+c_id,// 跳转到 action
            data:{
                     reply_id : reply_id
            },
            type:'post',
            cache:false,
            dataType:'json',
            success:function(data) {
                if(data.code =="0" ){
                    var html = template('circle_info',data);
                    $("#push_more").attr("onclick", "push_more_circe("+data.last_id+")")
                    $("#main").html($("#main").html()+html);
                }else{
                    view(data.msg);
                }
             },
             error : function() {
                  // view("异常！");
                  alert("异常！");
             }
        });
    }

    function chan_reply_status(reply_id, is_using) {
        if (is_using == 1){
            $.ajax( {
                url:'/replystatus',// 跳转到 action
                data:{
                         reply_id : reply_id,
                         is_using : 2
                },
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data) {
                    if(data.code =="0" ){
                        $("#i"+reply_id).attr("class", "aui-iconfont aui-icon-hide")
                        $("#div"+reply_id).attr("onclick", "chan_reply_status("+reply_id+", 2)")
                        $("#span"+reply_id).html("已屏蔽")
                    }else{
                        view(data.msg);
                    }
                 },
                 error : function() {
                      // view("异常！");
                      alert("异常！");
                 }
            });
        }else{
            $.ajax( {
                url:'/replystatus',// 跳转到 action
                data:{
                         reply_id : reply_id,
                         is_using : 1
                },
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data) {
                    if(data.code =="0" ){
                       $("#i"+reply_id).attr("class", "aui-iconfont aui-icon-display")
                        $("#div"+reply_id).attr("onclick", "chan_reply_status("+reply_id+", 1)")
                        $("#span"+reply_id).html("可见")
                    }else{
                        view(data.msg);
                    }
                 },
                 error : function() {
                      // view("异常！");
                      alert("异常！");
                 }
            });

        }

    }
    var c_id = getUrlParam('c_id');
    $.ajax( {
        url:'/replylist?c_id='+c_id,// 跳转到 action
        type:'post',
        cache:false,
        dataType:'json',
        success:function(data) {
            if(data.code =="0" ){
                var html = template('circle_info',data);
                $("#main").html("").html(html);
                $("#push_more").attr("onclick", "push_more_circe("+data.last_id+")")
            }else{
                view(data.msg);
            }
         },
         error : function() {
              // view("异常！");
              alert("异常！");
         }
    });
</script>
</html>